vpath %.c src
vpath %.o obj
CC=gcc
CFLAGS=-Wall -g $(INCLUDE) -fPIC
LIBS=
INCLUDE=-Iinclude
TARGET=$(SHARETARGET)
STATICTARGET=lib/libwk.a
SHARETARGET=lib/libwk.so
RM=-rm -f
OBJS=wk_dlist.o wk_hash.o wk_list.o wk_queue.o wk_queue_array.o \
wk_queue_link.o wk_slist.o wk_stack.o wk_stack_array.o wk_stack_link.o \
wk_string.o wk_tree.o wk_vector.o wk_element.o
all:$(OBJS)
	$(CC) -shared -fPCI -o $(TARGET) $(addprefix obj/,$(OBJS))
#生成静态库文件
staticlib:$(STATICTARGET)
$(STATICTARGET):$(OBJS)
	ar rcs $(STATICTARGET) $(addprefix obj/,$(OBJS))
#生成动态链接库文件
sharelib:$(SHARETARGET)
$(SHARETARGET):$(OBJS)
	$(CC) -shared -fPCI -o $(SHARETARGET) $(addprefix obj/,$(OBJS))
###############################
$(OBJS):%.o:%.c
	$(CC) -c $(CFLAGS) $< -o obj/$@
install:
	-sudo ln -s `pwd`/$(SHARETARGET) /usr/$(SHARETARGET)
	-sudo ln -s `pwd`/$(STATICTARGET) /usr/$(STATICTARGET)
	-sudo ln -s `pwd`/include /usr/include/wk
uninstall:
	-sudo rm -f /usr/$(SHARETARGET) /usr/$(STATICTARGET) \
	/usr/include/wk
clean:
	$(RM) $(SHARETARGET) $(STATICTARGET) $(addprefix obj/,$(OBJS))
